package com.ruoyi.web.controller.bl;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.bl.service.IBlCommonService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/bl/common")
public class BlCommonController extends BaseController {
    @Autowired
    IBlCommonService blCommonService;

    @Autowired
    ISysUserService sysUserService;
    /**
     * 查询后台所有状态正常的用户
     */
    @PreAuthorize("@ss.hasPermi('gas:gasBottle:list')")
    @GetMapping("/getSysUserList")
    public AjaxResult getSysUserList()
    {
        List<HashMap> list = blCommonService.selectAllSysUser();
        return success(list);
    }

    /**
     * 查询当前登录用户的信息
     */
    @PreAuthorize("@ss.hasPermi('gas:gasBottle:list')")
    @GetMapping("/getLoginSysUser")
    public AjaxResult getLoginSysUser()
    {
        SysUser sysUser = sysUserService.selectUserById(getUserId());
        sysUser.setPassword(null);
        return success(sysUser);
    }
}
